package org.mall.framework.util;

import org.mall.common.api.vo.CommonResult;
import org.mall.framework.constant.MallConstants;

import javax.servlet.ServletRequest;

public class MallUtil {

    public static String getUserId(ServletRequest request) {
        return (String) request.getAttribute(MallConstants.REQUEST_ATTR_USER_ID_KEY);
    }

    public static void setUserId(ServletRequest request, String userId) {
        request.setAttribute(MallConstants.REQUEST_ATTR_USER_ID_KEY, userId);
    }

    public static Integer getUserType(ServletRequest request) {
        return (Integer) request.getAttribute(MallConstants.REQUEST_ATTR_USER_TYPE_KEY);
    }

    public static void setUserType(ServletRequest request, Integer userType) {
        request.setAttribute(MallConstants.REQUEST_ATTR_USER_TYPE_KEY, userType);
    }

    public static CommonResult getCommonResult(ServletRequest request) {
        return (CommonResult) request.getAttribute(MallConstants.REQUEST_ATTR_COMMON_RESULT);
    }

    public static void setCommonResult(ServletRequest request, CommonResult result) {
        request.setAttribute(MallConstants.REQUEST_ATTR_COMMON_RESULT, result);
    }



}
